﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Liberate.CodeGenerator
{
    public partial class TargetFileSettingDialog : Form
    {
        public TemplateConfig Config { get; set; }
        public string ConfigFile { get; set; }
        
        public IList<VMFile> VMFiles { get; set; }

        public TargetFileSettingDialog()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            if(Config != null)
            {
                txtTemplateName.Text = Config.Name;
                txtTemplatePath.Text = ConfigFile;
                txtDescription.Text = Config.Description;
                VMFiles = new List<VMFile>();
                foreach (var file in Config.VMFiles)
                {
                    var copy = new VMFile {TargetFile = file.TargetFile, VMFilePath = file.VMFilePath};
                    VMFiles.Add(copy);
                    //vMFileBindingSource.Add(copy);
                }
                dgvVMFiles.DataSource = VMFiles;
            }
            base.OnLoad(e);
        }

        private void btnFinish_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
